package demo.hello_gg;

import gg.ui.application.GApplication;
import gg.ui.application.GGModule;
import gg.ui.view.GView;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;

import com.google.inject.Inject;
import com.google.inject.Module;

/**
 * 
 * 
 * 
 * 
 * @author Frank
 * 
 */
public class HelloGG {

    public static void main(String[] args) {

        final Module viewConfiguration = new GGModule() {
            protected void configure() {
                bindBaseViewTo(HelloGGView.class);
            }
        };
        new GApplication(viewConfiguration).launch();
    }

    public static final class HelloGGView implements GView {

        @Inject
        private JLabel helloGGLabel;

        public void layout(JPanel panel) {
            helloGGLabel.setText("Hello GG");
            panel.add(helloGGLabel);
        }
    }

    public static void equivalent() {

        final JLabel helloGGLabel = new JLabel("Hello GG");
        final JPanel panel = new JPanel();
        panel.add(helloGGLabel);
        final JFrame frame = new JFrame();
        frame.setContentPane(panel);
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.pack();
                frame.setLocationRelativeTo(null);
                frame.setVisible(true);
            }
        });
    }
}
